﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cole.Entities;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;


namespace Cole.Repository
{
    public class GradoRepository:MasterRepository,IGradoRepository
    {
        public List<GradoSeccion> GetGrado_Seccion(int id)
        {
            var query = _database.ExecuteSprocAccessor<GradoSeccion>("Grado_Seccion",id);
            return query.ToList();
        }



        public List<Grado> GetAllGrado()
        {
            var query = _database.ExecuteSprocAccessor<Grado>("GetAllGrado");
            return query.ToList();
        }


        public void ModificarGrado(GradoSeccion gradSeccion)
        {
            var command = _database.GetStoredProcCommand("registrarSeccion");
            _database.AddInParameter(command, "id", DbType.Int32, gradSeccion.ID);
            _database.AddInParameter(command, "nombres", DbType.String, gradSeccion.Nombre_Seccion);
            _database.AddInParameter(command, "id_grado", DbType.Int32, gradSeccion.ID_Grado);
            _database.ExecuteNonQuery(command);
        }


        public void nuevoGrado(Grado grado)
        {
            var command = _database.GetStoredProcCommand("registrarGrado");
            _database.AddInParameter(command, "id", DbType.Int32, grado.ID_Grado);
            _database.AddInParameter(command, "nombres", DbType.String, grado.Nombre_Grado);
            _database.ExecuteNonQuery(command);
        }


        public void eliminarSeccion(int id)
        {
            var command = _database.GetStoredProcCommand("DeleteSeccion");

            _database.AddInParameter(command, "id", DbType.Int32, id);

            _database.ExecuteNonQuery(command);
        }
    }
}
